#/usr/bin/env python
#-*-coding:utf-8-*-

"""
随机赋通用评论
"""

import random

out_path = "random_general_comment.csv"
general_comment_path = "./data/general_comment.csv"
video_path = "/data/download/no_comment_video.csv"

def load_comments(path):
    comments = []
    with open(path) as f:
        for _, line in enumerate(f):
            line = line.strip("\n").strip()
            if not line:
                continue
            comments.append(line)
    return comments

def load_video(path):
    videos = []
    with open(path) as f:
        for _, line in enumerate(f):
            line = line.strip("\n").strip()
            video = line.split("\t")
            videos.append(video)
    return videos

def assign_random():
    comments = load_comments(general_comment_path)
    videos = load_video(video_path)
    outf = open(out_path, 'w')
    for comment in comments:
        for i in range(2):
            video = random.choice(videos)
            video.append(comment)
            outf.write("\t".join(video)+"\n")


if __name__ == '__main__':
    assign_random()


